import {defineComponent, h, ref,reactive,watch,toRefs} from '@vue/runtime-core'
import  bullet  from '../assets/bunny-self.png'
import enemyBulletImg from '../assets/bunny.png'


export const enemyBulletInfo = {
    width: 61,
    height: 99,
    rotation: 0,
    dir: 1,
}
export const selfBulletInfo = {
    width: 61,
    height: 99,
    rotation: 0,
    dir: -1,
}
export default defineComponent({
    props:["x","y",'dir'],
    setup(props,ctx){
        const x = ref(props.x);
        const y = ref(props.y);
        const dir = ref(props.dir)
        //const {x,y} = toRefs(props)
        watch(props,(newVal)=>{
            x.value = newVal.x
            y.value = newVal.y
            dir.value = newVal.dir
        })

        return{
            X:x,
            Y:y,
            Dir:dir
        }
    },
    render(ctx) {
        return h("Sprite", {
            x: ctx.X,
            y: ctx.Y,
            texture: ctx.Dir === 1 ? enemyBulletImg : bullet
        });
    }
/*    render(ctx){
        //背景图片
        return h('Container',{x:ctx.X,y:ctx.Y},[ //这个要用定义的point的坐标
            h('Sprite',{texture:ctx.Dir===-1?bullet:enemyBulletImg})
        ])
    }*/
})